using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Newtonsoft.Json;
using System.IO;
using UnityEditor;

public class Item : MonoBehaviour
{
    public Image icon;
    public Button buyBtn;
    public Text text_Money;
    List<ShopData> shops = new List<ShopData>();
    ShopData shopData;
    public void Init(ShopData data)
    {
        shopData = data;
        icon.sprite=Instantiate(Resources.Load<Sprite>("Icon/"+data.icon));
        text_Money.text = data.Money.ToString();
        buyBtn.onClick.AddListener(BuyShopByBag);
    }
    private void BuyShopByBag()
    {
        if(MainGamePanelControlle.Instance.mainGamePanelModel.PlayerPropertyData.initJb>=shopData.Money)
        {
            MessCenter<ShopData>.Instance.DisPath(MsgID.AddBag, shopData);
        }
        MessCenter<int>.Instance.DisPath(MsgID.ExpendMoney, shopData.Money);
    }
}
